package org.vartist.atld.menu.activity.util.device;

import java.text.DecimalFormat;

import org.vartist.atld.R;
import org.vartist.atld.menu.consts.LayoutConst;
import org.vartist.atld.menu.consts.util.device.ConstDevice;
import org.vartist.atld.menu.listener.util.device.SetCallingDataClickListener;
import org.vartist.atld.menu.listener.util.device.SetDirectCallingClickListener;
import org.vartist.atld.menu.vo.util.device.DeviceVersionVO;
import org.vartist.atld.util.device.DeviceUtil;
import org.vartist.atld.util.device.MemoryUtil;
import org.vartist.atld.util.log.LogUtil;
import org.vartist.atld.util.ui.TitleUtil;
import org.vartist.atld.view.loading.LoadingCallback;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.telephony.CellLocation;
import android.telephony.PhoneNumberUtils;
import android.telephony.TelephonyManager;
import android.telephony.cdma.CdmaCellLocation;
import android.telephony.gsm.GsmCellLocation;
import android.util.DisplayMetrics;
import android.widget.Button;
import android.widget.TextView;

/**
 * @author sungsik81
 * 
 * necessary permission : 
 * <uses-permission android:name="android.permission.READ_PHONE_STATE" />
 * <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
 * <uses-permission android:name="android.permission.CALL_PHONE" />
 * <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
 *
 */
public class DeviceActivity extends Activity implements LoadingCallback {
	
	public static final String CALLING_NUMBER = "114";
	public static final String EMERGENCY_CALLING_NUMBER = "119";
	public static final String COMPARE_PHONE_NUMBER_ONE = "01012345678";
	public static final String COMPARE_PHONE_NUMBER_TWO = "010-1234-5678";
	
	/***
	 * device identification information
	 */
	private TextView mTxtTitle01 = null;
	private TextView mTxtCtnLabel = null;
	private TextView mTxtCtnValue = null;
	private TextView mTxtMdnLabel = null;
	private TextView mTxtMdnValue = null;
	private TextView mTxtDeviceIdLabel = null;
	private TextView mTxtDeviceIdValue = null;
	
	/***
	 * device phone status for network information
	 */
	private TextView mTxtTitle02 = null;
	private TextView mTxtCountryIsoLabel = null;
	private TextView mTxtCountryIsoValue = null;
	private TextView mTxtUsingWifiLabel = null;
	private TextView mTxtUsingWifiValue = null;
	private TextView mTxtAvailable3gLabel = null;
	private TextView mTxtAvailable3gValue = null;
	private TextView mTxtUsing3gBySystemPropertyLabel = null;
	private TextView mTxtUsing3gBySystemPropertyValue = null;
	private TextView mTxtUsingRoamingLabel = null;
	private TextView mTxtUsingRoamingValue = null;
	private TextView mTxtNetworkOperatorLabel = null;
	private TextView mTxtNetworkOperatorValue = null;
	private TextView mTxtNetworkOperatorNameLabel = null;
	private TextView mTxtNetworkOperatorNameValue = null;
	private TextView mTxtCallStateLabel = null;
	private TextView mTxtCallStateValue = null;	
	private TextView mTxtDataStateLabel = null;
	private TextView mTxtDataStateValue = null;	
	private TextView mTxtGsmCellIdLabel = null;
	private TextView mTxtGsmCellIdValue = null;	
	private TextView mTxtGsmLocationAreaCodeLabel = null;
	private TextView mTxtGsmLocationAreaCodeValue = null;	
	private TextView mTxtPhoneTypeLabel = null;
	private TextView mTxtPhoneTypeValue = null;
	private TextView mTxtNetworkTypeLabel = null;
	private TextView mTxtNetworkTypeValue = null;
	private TextView mTxtSimCardSerialNumberLabel = null;
	private TextView mTxtSimCardSerialNumberValue = null;
	
	/***
	 * device screen information
	 */
	private TextView mTxtTitle03 = null;
	private TextView mTxtScreenSizeLabel = null;
	private TextView mTxtScreenSizeValue = null;
	
	private TextView mTxtDensity = null;
	private TextView mTxtDensityD = null;
	private TextView mTxtDensityText = null;
	
	/***
	 * device memory information
	 */
	private TextView mTxtTitle04 = null;
	private TextView mTxtAvailableInternalMemorySizeLabel = null;
	private TextView mTxtAvailableInternalMemorySizeValue = null;
	private TextView mTxtAvailableExternalMemorySizeLabel = null;
	private TextView mTxtAvailableExternalMemorySizeValue = null;
	
	/***
	 * device caller calling sample
	 */
	private TextView mTxtTitle05 = null;
	private TextView mTxtSetCallingDataLabel = null;
	private Button mBtnSetCallingData = null;
	private TextView mTxtDirentCallingLabel = null;
	private Button mBtnDirentCalling = null;
	
	/***
	 * PhoneNumberUtils 
	 */
	private TextView mTxtTitle06 = null;
	private TextView mTxtEmergencyCallAbilityLabel = null;
	private TextView mTxtEmergencyCallAbilityValue = null;
	private TextView mTxtCompareTwoPhoneNumberLabel = null;
	private TextView mTxtCompareTwoPhoneNumberSample = null;
	private TextView mTxtCompareTwoPhoneNumberValue = null;
	
	/***
	 * S/W Version Infos
	 */
	private TextView mTxtTitle07 = null;
	private TextView mTxtSoftwareVersionLabel = null;
	private TextView mTxtSoftwareVersionValue = null;
	private TextView mTxtSwVersionCodeNameLabel = null;
	private TextView mTxtSwVersionCodeNameValue = null;
	private TextView mTxtSwVersionIncrementalLabel = null;
	private TextView mTxtSwVersionIncrementalValue = null;
	private TextView mTxtSwVersionReleaseLabel = null;
	private TextView mTxtSwVersionReleaseValue = null;
	private TextView mTxtSwVersionSdkLabel = null;
	private TextView mTxtSwVersionSdkValue = null;
	private TextView mTxtSwVersionSdkIntLabel = null;
	private TextView mTxtSwVersionSdkIntValue = null;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		LogUtil.debugNativeHeap();
		
		TitleUtil.setContentView(this, LayoutConst.LAYOUT_FOR_DEVICE, getString(R.string.app_name), getString(R.string.menu_util_device_name));
		getLayouts();
		
		setDeviceCtn();
		setDeviceMdn();
		setDeviceId();
		setDevideCallStatus();
		setDevideDataStatus();
		setSoftwareVersion();
		setCountryIso();
		setWifiStatus();
		set3gStatus();
		set3gStatusBySystemProperty();
		setRoaingStatus();
		setNetworkOperator();
		setNetworkOperatorName();
		setSimCardSerialNumber();
		setScreenSize();
		setInfoOfDpi();
		setAvailableInternalMemorySize();
		setAvailableExternalMemorySize();
		setCallerSample();
		setDirectCallingSample();
		setEmergencyCallAbility();
		setCompareTwoPhoneNumber();
		setPhoneType();
		setNetworkType();
		setGsmCellId();
		setGsmLocationAreaCode();
		setSwVersion();
	}
	
	private void setInfoOfDpi() {
	    DisplayMetrics metrics = DeviceUtil.getSecreenInfo(this);
	    mTxtDensityD.setText(metrics.densityDpi + "");
        mTxtDensity.setText(metrics.density + "");

        String text = DeviceUtil.getDensity(getApplicationContext());
        mTxtDensityText.setText(text + "");
    }

    private void setSimCardSerialNumber() {
		if (mTxtSimCardSerialNumberValue != null) {
			String simCardSerialNumber = DeviceUtil.getTelephonyManager(this).getSimSerialNumber();
			if (simCardSerialNumber != null && simCardSerialNumber.length() > 0) {
				mTxtSimCardSerialNumberValue.setText(simCardSerialNumber);
			}
		}
	}

	private void setNetworkOperatorName() {
		if (mTxtNetworkOperatorNameValue != null) {
			String networkOperatorName = DeviceUtil.getTelephonyManager(this).getNetworkOperatorName();
			if (networkOperatorName != null && networkOperatorName.length() > 0) {
				mTxtNetworkOperatorNameValue.setText(networkOperatorName);
			}
		}
	}

	private void setCountryIso() {
		if (mTxtCountryIsoValue != null) {
			String countryIso = DeviceUtil.getTelephonyManager(this).getNetworkCountryIso();
			if (countryIso != null && countryIso.length() > 0) {
				mTxtCountryIsoValue.setText(countryIso);
			}
		}
	}

	private void setSwVersion() {
		DeviceVersionVO versionVO = DeviceUtil.getDeviceSwVersionVO();
		
		if (mTxtSwVersionCodeNameValue != null) {
			mTxtSwVersionCodeNameValue.setText(versionVO.getCodeName());
		}
		if (mTxtSwVersionIncrementalValue != null) {
			mTxtSwVersionIncrementalValue.setText(versionVO.getIncremental());
		}
		if (mTxtSwVersionReleaseValue != null) {
			mTxtSwVersionReleaseValue.setText(versionVO.getRelease());
		}
		if (mTxtSwVersionSdkValue != null) {
			mTxtSwVersionSdkValue.setText(versionVO.getSdk());
		}
		if (mTxtSwVersionSdkIntValue != null) {
			mTxtSwVersionSdkIntValue.setText(versionVO.getSdkInt() + "");
		}
	}

	private void setSoftwareVersion() {
		if (mTxtSoftwareVersionValue != null) {
			String softwareVersion = DeviceUtil.getTelephonyManager(this).getDeviceSoftwareVersion();
			mTxtSoftwareVersionValue.setText(softwareVersion);
		} else {
			mTxtSoftwareVersionValue.setText("software version " + getString(R.string.data_is_null));
		}
	}

	private void setNetworkType() {
		if (mTxtNetworkTypeValue != null) {
			int networkType = getNetworkType();
			String networkTypeText = null;
			
			switch (networkType) {
				case ConstDevice.NETWORK_TYPE_UNKNOWN: //0
					networkTypeText = "NETWORK_TYPE_UNKNOWN";
					break;
				case ConstDevice.NETWORK_TYPE_GPRS: //1
					networkTypeText = "NETWORK_TYPE_GPRS";
					break;
				case ConstDevice.NETWORK_TYPE_EDGE://2
					networkTypeText = "NETWORK_TYPE_EDGE";
					break;
				case ConstDevice.NETWORK_TYPE_UMTS://3
					networkTypeText = "NETWORK_TYPE_UMTS";
					break;
				case ConstDevice.NETWORK_TYPE_CDMA://4
					networkTypeText = "NETWORK_TYPE_CDMA";
					break;
				case ConstDevice.NETWORK_TYPE_EVDO_0://5
					networkTypeText = "NETWORK_TYPE_EVDO_0";
					break;
				case ConstDevice.NETWORK_TYPE_EVDO_A://6
					networkTypeText = "NETWORK_TYPE_EVDO_A";
					break;
				case ConstDevice.NETWORK_TYPE_1xRTT://7
					networkTypeText = "NETWORK_TYPE_1xRTT";
					break;
				case ConstDevice.NETWORK_TYPE_HSDPA://8
					networkTypeText = "NETWORK_TYPE_HSDPA";
					break;
				case ConstDevice.NETWORK_TYPE_HSUPA://9
					networkTypeText = "NETWORK_TYPE_HSUPA";
					break;
				case ConstDevice.NETWORK_TYPE_HSPA://10
					networkTypeText = "NETWORK_TYPE_HSPA";
					break;
				case ConstDevice.NETWORK_TYPE_IDEN://11
					networkTypeText = "NETWORK_TYPE_IDEN";
					break;
				case ConstDevice.NETWORK_TYPE_EVDO_B://12
					networkTypeText = "NETWORK_TYPE_EVDO_B";
					break;
				case ConstDevice.NETWORK_TYPE_LTE://13
					networkTypeText = "NETWORK_TYPE_LTE";
					break;
				case ConstDevice.NETWORK_TYPE_EHRPD://14
					networkTypeText = "NETWORK_TYPE_EHRPD";
					break;				
				case ConstDevice.NETWORK_TYPE_HSPAP://15
					networkTypeText = "NETWORK_TYPE_HSPAP";
					break;				
			}
			
			mTxtNetworkTypeValue.setText(networkTypeText);
		}
	}
	
	private void setPhoneType() {
		if (mTxtPhoneTypeValue != null) {
			int phoneType = getPhoneType();
			String phoneTypeText = null;
			
			switch (phoneType) {
				case ConstDevice.PHONE_TYPE_NONE:
					phoneTypeText = "PHONE_TYPE_NONE";
					break;
				case ConstDevice.PHONE_TYPE_GSM:
					phoneTypeText = "PHONE_TYPE_GSM";
					break;
				case ConstDevice.PHONE_TYPE_CDMA:
					phoneTypeText = "PHONE_TYPE_CDMA";
					break;
				case ConstDevice.PHONE_TYPE_SIP:
					phoneTypeText = "PHONE_TYPE_SIP";
					break;				
			}
			
			mTxtPhoneTypeValue.setText(phoneTypeText);
		}
	}

	private int getPhoneType() {
		return DeviceUtil.getTelephonyManager(this).getPhoneType();
	}
	
	private int getNetworkType() {
		return DeviceUtil.getTelephonyManager(this).getNetworkType();
	}

	private void setGsmLocationAreaCode() {
		if (mTxtGsmLocationAreaCodeValue != null) {
			if (getPhoneType() == ConstDevice.PHONE_TYPE_GSM) {
				GsmCellLocation cellLocation = DeviceUtil.getDeviceGsmLocation(this);
				int locationAreaCode = cellLocation.getLac();
				mTxtGsmLocationAreaCodeValue.setText(locationAreaCode + "");
			} else {
				mTxtGsmLocationAreaCodeValue.setText("checkable only GSM phone");
				mTxtGsmLocationAreaCodeValue.setTextColor(Color.RED);
			}
		}
	}
	
	private void setGsmCellId() {
		if (mTxtGsmCellIdValue != null) {
			if (getPhoneType() == ConstDevice.PHONE_TYPE_GSM) {
				GsmCellLocation cellLocation = DeviceUtil.getDeviceGsmLocation(this);
				int cId = cellLocation.getCid();
				mTxtGsmCellIdValue.setText(cId + "");
			} else {
				mTxtGsmCellIdValue.setText("checkable only GSM phone");
				mTxtGsmCellIdValue.setTextColor(Color.RED);
			}			
		}
	}
		
	private void setDevideDataStatus() {
		if (mTxtDataStateValue != null) {
			int resultState = DeviceUtil.getDeviceDataState(this);
			String resultText = null;
			
			switch (resultState) {
				case TelephonyManager.DATA_CONNECTED:
					resultText = "DATA_CONNECTED";
					break;
				case TelephonyManager.DATA_CONNECTING:
					resultText = "DATA_CONNECTING";
					break;
				case TelephonyManager.DATA_DISCONNECTED:
					resultText = "DATA_DISCONNECTED";
					break;
				case TelephonyManager.DATA_SUSPENDED:
					resultText = "DATA_SUSPENDED";
					break;
			}
			
			if (resultText != null && resultText.length() > 0) {
				mTxtDataStateValue.setText(resultText);				
			}
		}
	}

	private void setDevideCallStatus() {
		if (mTxtCallStateValue != null) {
			int resultState = DeviceUtil.getDeviceCallState(this);
			String resultText = null;
			
			switch (resultState) {
				case TelephonyManager.CALL_STATE_IDLE:
					resultText = "CALL_STATE_IDLE";
					break;
				case TelephonyManager.CALL_STATE_OFFHOOK:
					resultText = "CALL_STATE_OFFHOOK";
					break;
				case TelephonyManager.CALL_STATE_RINGING:
					resultText = "CALL_STATE_RINGING";
					break;
			}
			
			if (resultText != null && resultText.length() > 0) {
				mTxtCallStateValue.setText(resultText);				
			}
		}
	}

	private void setCompareTwoPhoneNumber() {
		if (mTxtCompareTwoPhoneNumberSample != null) {
			mTxtCompareTwoPhoneNumberSample.setText("(" + COMPARE_PHONE_NUMBER_ONE + " and " + COMPARE_PHONE_NUMBER_TWO + ")");
			if (mTxtCompareTwoPhoneNumberValue != null) {
				boolean isSamePhoneNumber = PhoneNumberUtils.compare(COMPARE_PHONE_NUMBER_ONE, COMPARE_PHONE_NUMBER_TWO);
				mTxtCompareTwoPhoneNumberValue.setText(isSamePhoneNumber + "");
			}
		}
	}

	private void setEmergencyCallAbility() {
		if (mTxtEmergencyCallAbilityValue != null) {
			boolean isAvailableEmergencyCall = PhoneNumberUtils.isEmergencyNumber(EMERGENCY_CALLING_NUMBER);
			mTxtEmergencyCallAbilityValue.setText(isAvailableEmergencyCall + "");
		}
	}

	private void setDirectCallingSample(){
		if (mBtnDirentCalling != null) {
			mBtnDirentCalling.setOnClickListener(new SetDirectCallingClickListener(this, CALLING_NUMBER));
		}
	}
	
	private void setCallerSample() {
		if (mBtnSetCallingData != null) {
			mBtnSetCallingData.setOnClickListener(new SetCallingDataClickListener(this, CALLING_NUMBER));
		}
	}

	private void setAvailableExternalMemorySize() {
		if (mTxtAvailableExternalMemorySizeValue != null) {
			long availableMemorySizeTemp = MemoryUtil.getAvailableExternalMemorySize();
			long totalMemorySizeTemp = MemoryUtil.getTotalExternalMemorySize();
			
			float availableMemorySize = availableMemorySizeTemp;
			float totalMemorySize = totalMemorySizeTemp;
			
			if (availableMemorySize == -1.0 || totalMemorySize == -1.0) {
				mTxtAvailableExternalMemorySizeValue.setText("cannot check");
				mTxtAvailableExternalMemorySizeValue.setTextColor(Color.RED);
			} else {
				String availableMemorySizeText = changeSuffixAndFormatForExternalMemory(availableMemorySize);
				String totalMemorySizeText = changeSuffixAndFormatForExternalMemory(totalMemorySize);
				
				mTxtAvailableExternalMemorySizeValue.setText(availableMemorySizeText + " / " + totalMemorySizeText);
			}
		}
	}

	private void setAvailableInternalMemorySize() {
		if (mTxtAvailableInternalMemorySizeValue != null) {
			float availableMemorySize = Float.parseFloat(String.valueOf(MemoryUtil.getAvailableInternalMemorySize()));
			float totalMemorySize = Float.parseFloat(String.valueOf(MemoryUtil.getTotalInternalMemorySize()));
			
			String availableMemorySizeText = changeSuffixAndFotmatForInternalMemory(availableMemorySize);
			String totalMemorySizeText = changeSuffixAndFotmatForInternalMemory(totalMemorySize);
			
			mTxtAvailableInternalMemorySizeValue.setText(availableMemorySizeText + " / " + totalMemorySizeText);
		}
	}

	private String changeSuffixAndFormatForExternalMemory(float memorySize) {
		double memorySizeDouble = Double.valueOf(String.valueOf(memorySize));				
		
		String suffix = "";
		if (memorySizeDouble >= 1024) {
			memorySizeDouble = memorySizeDouble / 1024; //Bytes to KB
			suffix = "KB";
		}
		
		if (memorySizeDouble >= 1024) {
			memorySizeDouble = memorySizeDouble / 1024; //KB to MB
			suffix = "MB";
		}
		
		if (memorySizeDouble >= 1024) {
			memorySizeDouble = memorySizeDouble / 1024; //MB to GB
			suffix = "GB";
		}

		DecimalFormat decimalFormat = new DecimalFormat(".##");
		String availableMemorySizeText = decimalFormat.format(memorySizeDouble) + " " + suffix;
		
		return availableMemorySizeText;
	}
	
	private String changeSuffixAndFotmatForInternalMemory(float memorySize) {
		String memorySizeText = null;
		
		String suffix = "";
		if (memorySize >= 1024) {
			memorySize = memorySize / 1024; //Bytes to KB
			suffix = "KB";
		}
		
		if (memorySize >= 1024) {
			memorySize = memorySize / 1024; //KB to MB
			suffix = "MB";
		}
		
		if (memorySize >= 1024) {
			memorySize = memorySize / 1024; //MB to GB
			suffix = "GB";
		}

		DecimalFormat decimalFormat = new DecimalFormat(".##");
		memorySizeText = decimalFormat.format(memorySize);
		
		memorySizeText = memorySizeText + " " + suffix;
		return memorySizeText;
	}

	private void setScreenSize() {
		if (mTxtScreenSizeValue != null) {
			int widthSize = DeviceUtil.getDeviceScreenWidth(this);
			int heightSize = DeviceUtil.getDeviceScreenHeight(this);
			
			mTxtScreenSizeValue.setText(widthSize + "px X " + heightSize + "px (width X height)");
		}
	}

	private void setNetworkOperator() {
		if (mTxtNetworkOperatorValue != null) {
			String networkOperator = DeviceUtil.getNetworkOperator(this);
			if (networkOperator != null && networkOperator.length() > 0) {
				mTxtNetworkOperatorValue.setText(networkOperator);
			}
		}
	}

	private void setRoaingStatus() {
		if (mTxtUsingRoamingValue != null) {
			boolean isUsingRoaming = DeviceUtil.isUsingRoaming(this);
			mTxtUsingRoamingValue.setText(isUsingRoaming + "");
		}
	}

	private void set3gStatusBySystemProperty() {
		if (mTxtUsing3gBySystemPropertyValue != null) {
			boolean isUsing3gBySystemProperty = DeviceUtil.isConnect3g(this);
			mTxtUsing3gBySystemPropertyValue.setText(isUsing3gBySystemProperty + "");
		}		
	}

	private void set3gStatus() {
		if (mTxtAvailable3gValue != null) {
			boolean isUsing3g = DeviceUtil.isAvailable3g(this);
			mTxtAvailable3gValue.setText(isUsing3g + "");
		}
	}

	private void setWifiStatus() {
		if (mTxtUsingWifiValue != null) {
			boolean isUsingWifi = DeviceUtil.isUsingWifi(this);
			mTxtUsingWifiValue.setText(isUsingWifi + "");
		}
	}

	private void setDeviceId() {
		if (mTxtDeviceIdValue != null) {
			String deviceId = DeviceUtil.getDeviceId(this);
			if (deviceId != null && deviceId.length() > 0) {
				mTxtDeviceIdValue.setText(deviceId);
			}
		}
	}

	private void setDeviceMdn() {
		if (mTxtMdnValue != null) {
			String mdn = DeviceUtil.getDeviceMdn(this);
			if (mdn != null && mdn.length() > 0) {
				mdn = PhoneNumberUtils.formatNumber(mdn);
				mTxtMdnValue.setText(mdn);
			}
		}
	}

	private void setDeviceCtn() {
		if (mTxtCtnValue != null) {
			String ctn = DeviceUtil.getDeviceCtn(this);
			if (ctn != null && ctn.length() > 0) {
				ctn = PhoneNumberUtils.formatNumber(ctn);
				mTxtCtnValue.setText(ctn);
			}
		}
	}

	private void getLayouts() {
		mTxtTitle01 = (TextView) findViewById(R.id.txtTitle01);
		mTxtTitle01.setText("<Device identification information>");
		
		mTxtCtnLabel = (TextView) findViewById(R.id.txtCtnLabel);
		mTxtCtnLabel.setText("value of CTN : ");
		mTxtCtnValue = (TextView) findViewById(R.id.txtCtnValue);
		
		mTxtMdnLabel = (TextView) findViewById(R.id.txtMdnLabel);
		mTxtMdnLabel.setText("value of MDN : ");
		mTxtMdnValue = (TextView) findViewById(R.id.txtMdnValue);
		
		mTxtDeviceIdLabel = (TextView) findViewById(R.id.txtDeviceIdLabel);
		mTxtDeviceIdLabel.setText("value of DeviceId : ");
		mTxtDeviceIdValue = (TextView) findViewById(R.id.txtDeviceIdValue);
		
		mTxtTitle02 = (TextView) findViewById(R.id.txtTitle02);
		mTxtTitle02.setText("<Device phone status information>");
		
		mTxtCallStateLabel = (TextView) findViewById(R.id.txtCallStateLabel);
		mTxtCallStateLabel.setText("call state : ");
		mTxtCallStateValue = (TextView) findViewById(R.id.txtCallStateValue);
		
		mTxtDataStateLabel = (TextView) findViewById(R.id.txtDataStateLabel);
		mTxtDataStateLabel.setText("data state : ");
		mTxtDataStateValue = (TextView) findViewById(R.id.txtDataStateValue);
		
		mTxtGsmCellIdLabel = (TextView) findViewById(R.id.txtGsmCellIdLabel);
		mTxtGsmCellIdLabel.setText("[GSM] cell id : ");
		mTxtGsmCellIdValue = (TextView) findViewById(R.id.txtGsmCellIdValue);
		
		mTxtGsmLocationAreaCodeLabel = (TextView) findViewById(R.id.txtGsmLocationAreaCodeLabel);
		mTxtGsmLocationAreaCodeLabel.setText("[GSM] location area code : ");
		mTxtGsmLocationAreaCodeValue = (TextView) findViewById(R.id.txtGsmLocationAreaCodeValue);
		
		mTxtUsingWifiLabel = (TextView) findViewById(R.id.txtUsingWifiLabel);
		mTxtUsingWifiLabel.setText("wifi status : ");
		mTxtUsingWifiValue = (TextView) findViewById(R.id.txtUsingWifiValue);
		
		mTxtAvailable3gLabel = (TextView) findViewById(R.id.txtAvailable3gLabel);
		mTxtAvailable3gLabel.setText("3G availablity : ");
		mTxtAvailable3gValue = (TextView) findViewById(R.id.txtAvailable3gValue);
		
		mTxtUsing3gBySystemPropertyLabel = (TextView) findViewById(R.id.txtUsing3gBySystemPropertyLabel);
		mTxtUsing3gBySystemPropertyLabel.setText("3G status by system property : ");
		mTxtUsing3gBySystemPropertyValue = (TextView) findViewById(R.id.txtUsing3gBySystemPropertyValue);
		
		mTxtUsingRoamingLabel = (TextView) findViewById(R.id.txtUsingRoamingLabel);
		mTxtUsingRoamingLabel.setText("roaming status : ");
		mTxtUsingRoamingValue = (TextView) findViewById(R.id.txtUsingRoamingValue);
		
		mTxtNetworkOperatorLabel = (TextView) findViewById(R.id.txtNetworkOperatorLabel);
		mTxtNetworkOperatorLabel.setText("Network Operator : ");
		mTxtNetworkOperatorValue = (TextView) findViewById(R.id.txtNetworkOperatorValue);
		
		mTxtTitle03 = (TextView) findViewById(R.id.txtTitle03);
		mTxtTitle03.setText("<Device screen information>");
		
		mTxtScreenSizeLabel = (TextView) findViewById(R.id.txtScreenSizeLabel);
		mTxtScreenSizeLabel.setText("screen size : ");
		mTxtScreenSizeValue = (TextView) findViewById(R.id.txtScreenSizeValue);
		
		mTxtDensityD = (TextView) findViewById(R.id.textDensityD);
		mTxtDensity = (TextView) findViewById(R.id.textDensity);
		mTxtDensityText = (TextView) findViewById(R.id.textDensityText);
		
		mTxtTitle04 = (TextView) findViewById(R.id.txtTitle04);
		mTxtTitle04.setText("<Device memory information>");
		
		mTxtAvailableInternalMemorySizeLabel = (TextView) findViewById(R.id.txtAvailableMemoryInternalSizeLabel);
		mTxtAvailableInternalMemorySizeLabel.setText("available internal memory size : ");
		mTxtAvailableInternalMemorySizeValue = (TextView) findViewById(R.id.txtAvailableMemoryInternalSizeValue);
		
		mTxtAvailableExternalMemorySizeLabel = (TextView) findViewById(R.id.txtAvailableMemoryExternalSizeLabel);
		mTxtAvailableExternalMemorySizeLabel.setText("available external memory size : ");
		mTxtAvailableExternalMemorySizeValue = (TextView) findViewById(R.id.txtAvailableMemoryExternalSizeValue);
		
		mTxtTitle05 = (TextView) findViewById(R.id.txtTitle05);
		mTxtTitle05.setText("<Device caller calling sample>");
		
		mTxtSetCallingDataLabel = (TextView) findViewById(R.id.txtSetCallingDataLabel);
		mTxtSetCallingDataLabel.setText("set calling data (" + CALLING_NUMBER + ")");
		mBtnSetCallingData = (Button) findViewById(R.id.btnSetCallingData);
		
		mTxtDirentCallingLabel = (TextView) findViewById(R.id.txtDirentCallingLabel);
		mTxtDirentCallingLabel.setText("direct calling (" + CALLING_NUMBER + ")");
		mBtnDirentCalling = (Button) findViewById(R.id.btnDirentCalling);
		
		mTxtTitle06 = (TextView) findViewById(R.id.txtTitle06);
		mTxtTitle06.setText("<PhoneNumberUtils>");
		
		mTxtEmergencyCallAbilityLabel = (TextView) findViewById(R.id.txtEmergencyCallAbilityLabel);
		mTxtEmergencyCallAbilityLabel.setText("emergency call (" + EMERGENCY_CALLING_NUMBER + ") ability : ");
		mTxtEmergencyCallAbilityValue = (TextView) findViewById(R.id.txtEmergencyCallAbilityValue);
		
		mTxtCompareTwoPhoneNumberLabel = (TextView) findViewById(R.id.txtCompareTwoPhoneNumberLabel);
		mTxtCompareTwoPhoneNumberLabel.setText("compare two phone number");
		mTxtCompareTwoPhoneNumberValue = (TextView) findViewById(R.id.txtCompareTwoPhoneNumberValue);
		mTxtCompareTwoPhoneNumberSample = (TextView) findViewById(R.id.txtCompareTwoPhoneNumberSample);
		
		mTxtPhoneTypeLabel = (TextView) findViewById(R.id.txtPhoneTypeLabel);
		mTxtPhoneTypeLabel.setText("phone type : ");
		mTxtPhoneTypeValue = (TextView) findViewById(R.id.txtPhoneTypeValue);
		
		mTxtNetworkTypeLabel = (TextView) findViewById(R.id.txtNetworkTypeLabel);
		mTxtNetworkTypeLabel.setText("network type : ");
		mTxtNetworkTypeValue = (TextView) findViewById(R.id.txtNetworkTypeValue);
		
		mTxtTitle07 = (TextView) findViewById(R.id.txtTitle07);
		mTxtTitle07.setText("<S/W version Info>");

		mTxtSoftwareVersionLabel = (TextView) findViewById(R.id.txtSoftwareVersionLabel);
		mTxtSoftwareVersionLabel.setText("[T/M] Version : ");
		mTxtSoftwareVersionValue = (TextView) findViewById(R.id.txtSoftwareVersionValue);
		
		mTxtSwVersionCodeNameLabel = (TextView) findViewById(R.id.txtSwVersionCodeNameLabel);
		mTxtSwVersionCodeNameLabel.setText("[Build] CodeName : ");
		mTxtSwVersionCodeNameValue = (TextView) findViewById(R.id.txtSwVersionCodeNameValue);
		
		mTxtSwVersionIncrementalLabel = (TextView) findViewById(R.id.txtSwVersionIncrementalLabel);
		mTxtSwVersionIncrementalLabel.setText("[Build] Incremental : ");
		mTxtSwVersionIncrementalValue = (TextView) findViewById(R.id.txtSwVersionIncrementalValue);
		
		mTxtSwVersionReleaseLabel = (TextView) findViewById(R.id.txtSwVersionReleaseLabel);
		mTxtSwVersionReleaseLabel.setText("[Build] Release :");
		mTxtSwVersionReleaseValue = (TextView) findViewById(R.id.txtSwVersionReleaseValue);
		
		mTxtSwVersionSdkLabel = (TextView) findViewById(R.id.txtSwVersionSdkLabel);
		mTxtSwVersionSdkLabel.setText("[Build] SDK : ");
		mTxtSwVersionSdkValue = (TextView) findViewById(R.id.txtSwVersionSdkValue);
		
		mTxtSwVersionSdkIntLabel = (TextView) findViewById(R.id.txtSwVersionSdkIntLabel);
		mTxtSwVersionSdkIntLabel.setText("[Build] SDK_INT : ");
		mTxtSwVersionSdkIntValue = (TextView) findViewById(R.id.txtSwVersionSdkIntValue);
		
		mTxtCountryIsoLabel = (TextView) findViewById(R.id.txtCountryIsoLabel);
		mTxtCountryIsoLabel.setText("Country ISO : ");
		mTxtCountryIsoValue = (TextView) findViewById(R.id.txtCountryIsoValue);
		
		mTxtNetworkOperatorNameLabel = (TextView) findViewById(R.id.txtNetworkOperatorNameLabel);
		mTxtNetworkOperatorNameLabel.setText("Network Operator Name : ");
		mTxtNetworkOperatorNameValue = (TextView) findViewById(R.id.txtNetworkOperatorNameValue);
		
		mTxtSimCardSerialNumberLabel = (TextView) findViewById(R.id.txtSimCardSerialNumberLabel);
		mTxtSimCardSerialNumberLabel.setText("Sim Card Serial Number : ");
		mTxtSimCardSerialNumberValue = (TextView) findViewById(R.id.txtSimCardSerialNumberValue);
	}
	
	@Override
	public void onBackkeyDown() {
		
	}

}
